<?php

namespace app\api\controller;

use app\BaseController;
use Ramsey\Uuid\Uuid;

class Business extends BaseController
{
    /**
     * 企业业务开通与变更
     * @return \think\response\Json|void
     */
    public function business_process()
    {
        if (request()->post()) {
            $params = input("post.");
            $authorizecode = strtoupper(str_replace('-', '', Uuid::uuid4()->toString()));
            $data = [
                "authorizecode" => $authorizecode,
                "applyno" => $params['applyno'],
                "ecordercode" => $params['ecordercode'],
                "opttype" => $params['opttype'],
                "trial" => $params['trial'],
                "bossorderid" => $params['bossorderid'],
                "custid" => $params['custid'],
                "custcode" => $params['custcode'],
                "registersource" => $params['registersource'],
                "custtype" => $params['custtype'],
                "userid" => $params['userid'],
                "username" => $params['username'],
                "mobile" => $params['mobile'],
                "email" => $params['email'],
                "productcode" => $params['productcode'],
                "endtime" => $params['endtime'],
                "productparas" => $params['productparas'],

            ];
            $data["services"] = [];
            foreach ($params['services'] as $key => $value) {
                array_push($data["services"], $value);
            }
            return json(["result" => true, "errmsg" => "", "authorizecode" => $authorizecode]);
        }
    }

    /**
     *  企业业务状态变更
     * @return \think\response\Json|void
     */
    public function business_status_change()
    {
        if (request()->post()) {
            $params = input("post.");
            $data = [
                "applyno" => "SAAS-O-2276CEA72C534304B3502A416F57BA0D",
                "ecordercode" => "7e21c2fdf9ab48be849e308e4a2741f2",
                "opttype" => 0,
                "custid" => 2103,
                "custcode" => "E0002018042810010053",
                "productcode" => "111800",
                "operatime" => 1541998430477,
                "effecttime" => 1541952000000
            ];
            $data["services"] = [];
            foreach ($params['services'] as $key => $value) {
                array_push($data["services"], $value);
            }

            return json(["result" => true, "errmsg" => ""]);
        }
    }


    /**
     * 成员业务开通与变更
     * @return \think\response\Json|void
     */
    public function business_member_process()
    {
        if (request()->post()) {
            $params = input("post.");
            $data = [
                "applyno" => "SAAS-O-A51A3AC7CB26448484F4C62C5D139BC4",
                "ecordercode" => "5e5508e871144d1586094ad0229ad732",
                "custid" => "500263",
                "productcode" => "111800"

            ];
            foreach ($params['users'] as $key => $value) {
                array_push($data["services"], $value);
            }
            return json(["result" => true, "errmsg" => ""]);
        }
    }


    /**
     *  成员业务状态变更
     * @return \think\response\Json|void
     */
    public function business_member_status_change()
    {
        if (request()->post()) {
            $params = input("post.");
            $data = [
                "applyno" => "SAAS-O-2276CEA72C534304B3502A416F57BA0D",
                "ecordercode" => "7e21c2fdf9ab48be849e308e4a2741f2",
                "opttype" => 0,
                "custid" => 2103,
                "custcode" => "E0002018042810010053",
                "productcode" => "111800",
                "operatime" => 1541998430477,
                "effecttime" => 1541952000000
            ];
            $data["services"] = [];
            foreach ($params['services'] as $key => $value) {
                array_push($data["services"], $value);
            }

            return json(["result" => true, "errmsg" => ""]);
        }
    }

}